package birdsong.comm;

/**
 * Messages sent from the server to clients. A message contains a type (enum), a payload (String), 
 * and a sender (String). 
 * <p>
 * <b>Important:</b> <br>
 * A <i>message</i> refers to an object sent from the server to a client.<br>
 * A <i>Birdsong message</i> refers to an object sent from a client to his or her followers<br>
 * 
 * <p>
 * When a Birdsong message is being sent from one user to followers, the sender
 * is the nickname of the client. For all other messages the sender's nickname should be {@link #SERVER}. 
 * <p>
 * The payload varies depending on the message type.
 * 
 * @author alc
 * @version 1 
 */
public interface ClientSideMessage {
	
	public static final String SERVER = "server";
	
	/**
	 * Message types.
	 */
	public enum Type { 
		/**
		 * A new client has connected. Message payload = nickname of newly connected client.
		 */
		CONNECTED, 
		/**
		 * A client has disconnected. Message payload = nickname of disconnecting client.
		 */
		DISCONNECTED, 

		/**
		 * A new Birdsong message from a followed client. Message payload = Birdsong message.
		 */
		BIRDSONG_MESSAGE, 

		/**
		 * A client received a new follower. Message payload = nickname of follower.
		 */
		FOLLOWER, 
		
		/**
		 * A follower decided to unfollow. Message payload = nickname of unfollower.
		 */
		UNFOLLOWER, 

		/**
		 * An error occurred. Message payload = description of the error.
		 */
		ERROR };

	/**
	 * Gets the type of the message.
	 * 
	 * @return type of the message.
	 */
	public Type getType();

	/**
	 * Gets the payload of the message.
	 * 
	 * @return payload.
	 */
	
	public String getPayload();

	/**
	 * Gets the sender of the message. The sender is the nickname of the message sender in case the message sent is 
	 * a Birdsong message from one client to another. For all other messages. The sender will be {@link #SERVER}
	 * 
	 * @return nickname of the sender.
	 */
	public String getSendersNickname();
}
